let globalData = getApp().globalData;
import tui from '../../../common/httpRequest'
Page({
  data: {
    name: 'echo.', //昵称
    isLogin: false
  },
  onShow: function() {
    let isLogin = globalData.isLogin;
    if (isLogin) {
      this.setData({
        isLogin: isLogin,
        name: globalData.mobile
      });
    }
  },
  logout: function() {
    tui.modal("提示", "确定退出登录？", true, (res) => {
      if (res) {
        wx.clearStorage();
        wx.reLaunch({
          url: '/pages/common/login/login'
        });
      }
    })
  },
  edit() {
    tui.toast('功能开发中~');
  },
  tapEvent: function(e) {
    let index = e.currentTarget.dataset.index;
    let url = "";
    if (index == 1) {
      url = '/pages/common/about/about'
    } else if (index == 2) {
      let key = e.currentTarget.dataset.key;
      url = '/pages/index/maps/maps?key=' + key;
    } else {
      url = '/pages/common/log/log'
    }
    tui.href(url)
  },
  github: function () {
    tui.copy("https://github.com/dingyong0214/ThorUI","链接已复制")
  },
  previewReward: function () {
    wx.previewImage({
      urls: ['https://thorui.cn/img/reward.jpg']
    });
  },
  openThorUI() {
    wx.navigateToMiniProgram({
      appId: 'wxd3c1da92cb8fcf40'
    });
  },
  onShareAppMessage: function () {
    return {
      title: "ThorUI组件库"
    }
  }
})